import 'package:flutter/foundation.dart';

@immutable
class DownloadRecord {
  const DownloadRecord({
    required this.version,
    required this.downloadId,
  });

  factory DownloadRecord.fromJson(Map<String, dynamic> json) {
    return DownloadRecord(
      version: json['version'] as Object,
      downloadId: json['downloadId'] as int,
    );
  }

  final Object version;
  final int downloadId;

  @override
  bool operator ==(Object other) {
    return other.runtimeType == DownloadRecord &&
        other is DownloadRecord &&
        other.version == version &&
        other.downloadId == downloadId;
  }

  @override
  int get hashCode {
    return Object.hashAll(<Object?>[
      version,
      downloadId,
    ]);
  }

  Map<String, dynamic> toJson() {
    return <String, dynamic>{
      'version': version,
      'downloadId': downloadId,
    };
  }

  DownloadRecord copyWith({
    Object? version,
    int? downloadId,
  }) {
    return DownloadRecord(
      version: version ?? this.version,
      downloadId: downloadId ?? this.downloadId,
    );
  }
}
